/*
 * @Author: 
 * @Date: 2022-08-30 09:54:56
 * @LastEditors: 
 * @LastEditTime: 2022-09-06 17:53:03
 * @Description: file content
 * @FilePath: \visualization\vite.config.js
 */

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const { resolve } = require("path")
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue()],
    // 静态资源基础路径 base: './' || '',
    base: process.env.NODE_ENV === 'production' ? './' : '/',
    css: {
        // 配置全局样式
        preprocessorOptions: {
            scss: {
                // additionalData: `@import ${resolve(__dirname, './src/assets/style/index.scss')};`
                additionalData: `@import '@/assets/style/index.scss';`
            }
        },
        postcss: {
            plugins: [
                require("postcss-px2rem")({
                    remUnit: 16
                })
            ]
        }
    },
    resolve: {
        alias: [{
            find: "@",
            replacement: resolve(__dirname, "./src")
        }],
        dedupe: ["vue"]
    },
    server: {
        host: "0.0.0.0",
        port: 8080,
        open: true,
        strictPort: true,
        proxy: {
            '/api': {
              target: 'http://192.168.1.84:8966/',
              changeOrigin: true,
              rewrite: path => path.replace(/^\/api/, '')
            }
          }
    },
    build: {
        outDir: "dist",
        assetsDir: "assets",
        cssCodeSplit: true,
        sourcemap: false,
        terserOptions: {
            compress: {
                // 生产环境移除console
                drop_console: true,
                // 生产环境移除debugger
                drop_debugger: true
            }
        }
    }
})